package cn.com.surker.workcon.service.xugong;

import cn.com.surker.base.system.entity.SysLine;
import cn.com.surker.production.entity.vo.ProductionIndentVo;
import cn.com.surker.workcon.common.GKJDBCService;
import cn.com.surker.workcon.common.RecipeTranEntity;
import cn.com.surker.workcon.service.RecipeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 工控上传配比接口 Mapper 接口
 * </p>
 *
 * @author admin
 * @since 2024-09-26
 */
@Slf4j
public class RecipeServiceImpl extends GKJDBCService implements RecipeService {

	/**
	 * 上传配合比数据
	 *
	 * @param line    工控机生产线
	 * @param indent  任务单信息
	 * @param code    配合比编号(砂浆在配合比前加入R)
	 * @param betLev  强度等级名
	 * @param filter  抗渗等级
	 * @param freeze  抗冻等级
	 * @param season  施工季节
	 * @param mixLast 搅拌时间
	 * @param exper   试验员
	 * @param assoss  审核员
	 * @param list    配合比数据
	 * @return
	 */
	@Override
	public Long uploadExpend(SysLine line, ProductionIndentVo indent, String code, String betLev, String filter, String freeze, String season,
							 Integer mixLast, String scale, String exper, String assoss, List<RecipeTranEntity> list, Date nowDate) {
		if (line == null || indent == null || list == null || list.isEmpty()) {
			return -1l;
		}
		Long lineId = line.getId();
		//	获取连接
		JdbcTemplate lineJdbcTemp = getLineJdbcTemp(line);
		//	任务单编号
		String indentCode = indent.getCode();
		//	插入sql
		String recipeTable = XgUtil.getDockTableName(line, "Formula");
		//	组装sql
		String recipeSql = "insert into " + recipeTable + " (FormulaCode,LineCode,BinCode,BinName,BomCode,BomName,FormulaValue) values (?,?,?,?,?,?,?)";
		//	查询料仓信息
		String storeTable = XgUtil.getDockTableName(line, "BinAndBom");
		String selectStoreSql = "select * from " + storeTable;
		List<Map<String, Object>> storeList = lineJdbcTemp.queryForList(selectStoreSql);
		//	开启事务
		beginTransaction(lineId);

		return 1l;
	}


}
